/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.scrumpmt.domain;

import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author agumpg
 */
@Entity
@Table(name = "COLABORADOR")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Colaborador.findAll", query = "SELECT c FROM Colaborador c"),
    @NamedQuery(name = "Colaborador.findById", query = "SELECT c FROM Colaborador c WHERE c.id = :id"),
    @NamedQuery(name = "Colaborador.findByNombre", query = "SELECT c FROM Colaborador c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Colaborador.findByPassword", query = "SELECT c FROM Colaborador c WHERE c.password = :password"),
    @NamedQuery(name = "Colaborador.findByMail", query = "SELECT c FROM Colaborador c WHERE c.mail = :mail"),
    @NamedQuery(name = "Colaborador.findByAdministrador", query = "SELECT c FROM Colaborador c WHERE c.administrador = :administrador")})
public class Colaborador extends BaseEntity {    
    @Column(name = "nombre", nullable=false)
    private String nombre;
    @Column(name = "password", nullable=false)
    private String password;
    @Column(name = "mail", nullable=false)
    private String mail;
    @Column(name = "administrador", nullable=false)
    private Boolean administrador;
    @JoinTable(name = "EQUIPO", joinColumns = {
        @JoinColumn(name = "id_colaborador_fk", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "id_proyecto_fk", referencedColumnName = "id")})
    @ManyToMany
    private Collection<Proyecto> proyectoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idColaboradorFk")
    private Collection<Tarea> tareaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idScrumMaster")
    private Collection<Proyecto> proyectoCollection1;

    public Colaborador() {
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public Boolean getAdministrador() {
        return administrador;
    }

    public void setAdministrador(Boolean administrador) {
        this.administrador = administrador;
    }

    @XmlTransient
    public Collection<Proyecto> getProyectoCollection() {
        return proyectoCollection;
    }

    public void setProyectoCollection(Collection<Proyecto> proyectoCollection) {
        this.proyectoCollection = proyectoCollection;
    }

    @XmlTransient
    public Collection<Tarea> getTareaCollection() {
        return tareaCollection;
    }

    public void setTareaCollection(Collection<Tarea> tareaCollection) {
        this.tareaCollection = tareaCollection;
    }

    @XmlTransient
    public Collection<Proyecto> getProyectoCollection1() {
        return proyectoCollection1;
    }

    public void setProyectoCollection1(Collection<Proyecto> proyectoCollection1) {
        this.proyectoCollection1 = proyectoCollection1;
    }
    
    @Override
    public String toString() {
        return this.getNombre();
    }
    
}
